//
//  UgcFriendsTbvHead.m
//  ZITHER
//
//  Created by weixin on 2018/11/12.
//  Copyright © 2018 weixn. All rights reserved.
//

#import "Ugc_Friends_TbvHead_WX.h"

@implementation Ugc_Friends_TbvHead_WX


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor colorWithHex:@"F5F5F5"];
        [self addSubview:self.lab];
        [self addSubview:self.btn];
        [self.lab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(20);
            make.centerX.equalTo(self.mas_centerX).offset(0);
        }];
        
        [self.btn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.lab.mas_bottom).offset(20);
            make.centerX.equalTo(self.mas_centerX).offset(0);
            make.height.mas_equalTo(25);
            make.width.mas_equalTo(80);

            make.bottom.equalTo(self).offset(-20);
        }];
    }
    return self;
}


-(void)isType:(NSInteger)index{
    if (index == 0) {
        self.frame = CGRectMake(0, 0, kScreenW, 60);
        
        self.lab.text = @"推荐给你";
        self.lab.backgroundColor = [UIColor clearColor];
        self.lab.hidden = NO;
        self.btn.hidden = YES;
        self.findView.hidden = YES;
        [self.lab mas_updateConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(20);
            make.centerX.equalTo(self.mas_centerX).offset(0);
        }];
        
        [self.btn mas_updateConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.lab.mas_bottom).offset(0);
            make.height.mas_equalTo(0);
        }];

        
    }else if (index == 2){
        self.frame = CGRectMake(0, 0, kScreenW, 20);
        self.lab.hidden = YES;
        self.btn.hidden = YES;
        self.findView.hidden = YES;
        self.backgroundColor = [UIColor whiteColor];
        [self addSubview:self.findView];
    }else{
        self.frame = CGRectMake(0, 0, kScreenW, 100);
        self.lab.text = @"登录查看我的关注";
        self.lab.hidden = NO;
        self.btn.hidden = NO;
        self.findView.hidden = YES;
        [self.lab mas_updateConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(20);
            make.centerX.equalTo(self.mas_centerX).offset(0);
        }];
        
        [self.btn mas_updateConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.lab.mas_bottom).offset(20);
            make.height.mas_equalTo(25);
        }];

    }
}

-(BaseLab *)lab{
    if (!_lab) {
        _lab = [[BaseLab alloc]initializeFrame:CGRectMake(0, 0, 1, 1) text:@"推荐给你" font:12 textColor:[UIColor colorWithHex:@"999999"] isBold:NO numberOfLines:1];
        _lab.font = [UIFont fontWithName:@"PingFangSC-Medium" size:12];
        _lab.backgroundColor = [UIColor colorWithHex:@"F5F5F5"];

    }
    return _lab;
}

-(BaseBtn *)btn{
    if (!_btn) {
        _btn = [[BaseBtn alloc]initWithFrame:CGRectMake(0, 0, 1, 1)];
        [_btn setCornerRadiusWithRadius:4 isMasks:YES];
        [_btn setTitle:@"登录" forState:UIControlStateNormal];
        [_btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _btn.backgroundColor = baseColorTheme;
        _btn.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size:12];
        @weakify(self);
        [[_btn rac_signalForControlEvents:(UIControlEventTouchUpInside)] subscribeNext:^(__kindof UIControl * _Nullable x) {
            [Tools pushMeRegisterVC];
        }];
    }
    return _btn;
}

-(Ugc_Friends_TbvHeadFind_WX *)findView{
    if (!_findView) {
        _findView = [[Ugc_Friends_TbvHeadFind_WX alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 50)];
    }
    return _findView;
}


@end
